package com.example.kuaizu.controller;

import com.example.kuaizu.pojo.pram.CreateResumePram;
import com.example.kuaizu.pojo.pram.QueryResumePram;
import com.example.kuaizu.pojo.pram.UpdateResumePram;
import com.example.kuaizu.service.InResumeFunctionService;
import com.example.kuaizu.utils.AjaxResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: wangmx15
 * @date: 2025/10/6
 **/
@Log4j2
@RestController
@RequestMapping("/resume")
@RequiredArgsConstructor
public class ResumeFunctionController {
    private final InResumeFunctionService resumeFunctionService;

    /**
     * 创建简历
     *
     * @param pram
     * @return
     */
    @PostMapping("/createResume")
    public AjaxResponse createResume(@RequestBody @Validated CreateResumePram pram) {
        resumeFunctionService.createResume(pram);
        return AjaxResponse.success("创建成功");
    }

    /**
     * 查询自己的全部简历
     *
     * @param pram
     * @return
     */
    @PostMapping("/queryMyResumeAll")
    public AjaxResponse queryMyResumeAll() {
        return AjaxResponse.success("查询成功", resumeFunctionService.queryMyResumeAll());
    }

    /**
     * 查询指定的简历
     *
     * @param pram
     * @return
     */
    @PostMapping("/queryResume")
    public AjaxResponse queryResume(@RequestBody @Validated QueryResumePram pram) {
        return AjaxResponse.success("查询成功", resumeFunctionService.queryResume(pram));
    }

    /**
     * 删除简历
     *
     * @param pram
     * @return
     */
    @PostMapping("/deleteResume")
    public AjaxResponse deleteResume(@RequestBody @Validated QueryResumePram pram) {
        resumeFunctionService.delectResume(pram.getId());
        return AjaxResponse.success("删除成功");
    }

    /**
     * 修改简历
     *
     * @param pram
     * @return
     */
    @PostMapping("/updateResume")
    public AjaxResponse updateResume(@RequestBody @Validated UpdateResumePram pram) {
        resumeFunctionService.updateResume(pram);
        return AjaxResponse.success("修改成功");
    }

}
